package com.yoshino.principle.dependence_inversion;


import lombok.extern.slf4j.Slf4j;

/**
 * 定义接口
 */
interface IReceiver {
    /**
     * 接收信息
     *
     * @return
     */
    String getInfo();
}

/**
 * @author yoshino
 **/
@Slf4j
public class DependenceInversion {

    public static void main(String[] args) {
        Person person = new Person();
        person.receive(new Email());
        person.receive(new WeiXin());
    }
}

class Email implements IReceiver {
    @Override
    public String getInfo() {
        return "电子邮件信息:" + "hello";
    }
}

class WeiXin implements IReceiver {

    @Override
    public String getInfo() {
        return "微信消息:" + "hello";
    }
}

@Slf4j
class Person {
    /**
     * 这里是对接口的依赖
     */
    public void receive(IReceiver email) {
        log.info(email.getInfo());
    }
}